<%@page language="java" contentType="text/html; charset=utf-8"%>
<%@include file="/tagDeclare.jsp"%>
<%@include file="/headDeclare.jsp"%>
<html>
<head>
<style type="text/css">
</style>

<script type="text/javascript">

	$(document).ready(function() { 
		
		$().piroBox({my_speed: 200,bg_alpha: 0.1,slideShow : true,slideSpeed : 4,close_all : '.piro_close,.piro_overlay'});
		//
		$("#wallTable").tablesorter({theme:'green',
			headers:{0:{sorter:false},
       			1:{sorter:false},
       			2:{sorter:false},
       			3:{sorter:false},
       			4:{sorter:false},
       			5:{sorter:false},
       			6:{sorter:true},
       			7:{sorter:false},
       			8:{sorter:true},
       			9:{sorter:false},
       			10:{sorter:false},
       			11:{sorter:true},
       			12:{sorter:true},
       			13:{sorter:false},
       			14:{sorter:false},
       			15:{sorter:false}}
       	});
       	
        $("#btn_insert").click(function(){
            var queryString = $("#wallForm").formSerialize();
            queryString = encodeURIComponent(queryString);
            location.href = "<%=basePath%>wall/insert.do?qs=" + queryString;
        });
        
        $("#btn_search").click(function(){
            $("#curPage").val(1);
            $("#wallForm").submit();
        });
        
        //批量删除
        $("#btn_batch_del").click(function(){
        	var ids = null;
        	$("input[name='checkName']:checkbox:checked").each(function(){ 
        		if(ids == null)
        			ids = $(this).val();
        		else
        		    ids +=","+$(this).val() ;
        	}) ;
        	if(ids==null || ids == "")
        		{
        			$.ligerDialog.alert("请选择");
        			return;
        		}
        	location.href = "<%=basePath%>wall/batchDelete.do?ids=" + ids;
        });
        
        //批量导出
        $("#btn_export").click(function(){
        	var ids = "";
        	$("input[name='checkName']:checkbox:checked").each(function(){ 
        		if(ids == "")
        			ids = $(this).val();
        		else
        		    ids +=","+$(this).val() ;
        	}) ;
        	if(ids != ""){
       			$("#ids").val(ids);
       		}
        	$("#wallForm").attr("action","wall/batchExport.do");
        	$("#wallForm").submit();
        	$("#wallForm").attr("action","wall/list.do");
        	$("#ids").val("");
        });
        
        $("#btn_import").click(function(){
        	var filePath = $("#filePath").val();
        	var num = Math.random();
        	$.post("<%=basePath%>wall/import.do", { path: filePath,num:num},function(data){
       			   //由JSON字符串转换为JSON对象
       			   var responseJson = eval('(' + data + ')');
       			   if(responseJson.code==0)
       			   {
       					$('#error_label').text("错误信息：" + responseJson.message);
   		         		return;
       			   }else{
       					location.href = "<%=basePath%>wall/list.do";
					}
				});
		});

		$("#btn_change").click(function() {
			var page = parseInt($("#selectPage").val());
			var curPage = parseInt($("#curPage").val());
			if (curPage == page)
				return;
			$("#curPage").val(parseInt(page));
			$("#wallForm").submit();
		});
				
		 $("#btn_image_change").click(function(){
        	$.post("<%=basePath%>image/init.do", '',function(data){
       			   //由JSON字符串转换为JSON对象
       			   var responseJson = eval('(' + data + ')');
       			   if(responseJson.code==0)
       			   {
       					$('#error_label').text("错误信息：" + responseJson.message);
   		         		return;
       			   }else{
       					$.ligerDialog.alert("图片转移完成");
					}
				});
		});
				 
		 var options = {dataType: 'json', success : process};
		 	$("#uploadFrom").submit(function(){
	               $(this).ajaxSubmit(options);
	               return false;
	 	});
		
	});
	
	function process(responseJson) {
	   if(responseJson.code==0)
	   {
		   	$.ligerDialog.error(responseJson.message);
        	return;
	   }else{
			location.href = "<%=basePath%>wall/list.do";
		}
	}

	function view(id,addr){
		var queryString = $("#wallForm").formSerialize();
        queryString = encodeURIComponent(queryString);
       	var url = "<%=basePath%>wall/view.do?id=" + id + "&qs=" + queryString;
       	window.parent.f_addTab('view'+id,"查看:"+addr+"的墙体",url);
	};
	
	function updateItem(username,id){
		var url = "<%=basePath%>wall/update.do?id="+id;
		window.parent.f_addTab('update'+id,"修改:"+username+"的墙体",url);
	}

	function init() {
		var province = $("#selectedProvince").val();
		var city = $("#selectedCity").val();
		var county = $("#selectedCounty").val();
		var json = eval("(" + shiData + ")");
		if (province != "") {
			province = "福建省";
			str = '<option value="'+province+'" selected >' + province
					+ ' </option>';
			$("#province").append(str);
		} else {
			province = "福建省";
			str = '<option value="'+province+'" >' + province + ' </option>';
			$("#province").append(str);
		}
		var citys = json[province];
		$(citys).each(
				function(i) {
					var c = citys[i];
					if (c.id == city)
						str = '<option value="'+c.id+'" selected >' + c.name
								+ ' </option>';
					else
						str = '<option value="'+c.id+'"  >' + c.name
								+ ' </option>';
					$("#city").append(str);
				});

		json = eval("(" + xianData + ")");
		var countys = json[city];
		$(countys).each(
				function(i) {
					var co = countys[i];
					if (co.id == county)
						str = '<option value="'+co.id+'" selected >' + co.name
								+ ' </option>';
					else
						str = '<option value="'+co.id+'"  >' + co.name
								+ ' </option>';
					$("#county").append(str);
				});
	}
	
	
	
	
</script>
</head>

<body onload="init()">
	<%-- 	<input id="sort" type="hidden" value="${username_attr. }" /> --%>
	<input id="selectedProvince" type="hidden" value="${province}" />
	<input id="selectedCity" type="hidden" value="${city }" />
	<input id="selectedCounty" type="hidden" value="${county }" />
	<div style="width: 100%;">
		<div style="margin-top: 10px;text-align: center;" >
				<form id="wallForm" method="post" name="wallForm" action="wall/list.do">
					<input type="hidden" name="ids" id="ids" />
					<table >
						<tr>
							<td style="width: 80px;text-align: right;">
								省市县:
							</td>
							<td style="width: 300px;text-align: left;">
								<select id="province" name="province" onchange="selectSheng()" class="ldText" style="width: 70px;">
									<option value="">-省-</option>
								</select>
								<select id="city" name="city" onchange="selectShi();" class="ldText" style="width: 70px;">
									<option value="">-市-</option>
								</select>
								<select id="county" name="county" class="ldText" style="width: 70px;">
									<option value="">-县-</option>
								</select>
							</td>
							<td style="width: 80px;text-align: right;">
								到期时间:
							</td>
							<td style="width: 300px;text-align: left;">
								<input type="text" name="endTime" id="endTime" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" class="Wdate ldDate ldText" value="${endTime }" />
							</td>
							<td style="width: 80px;text-align: right;">
								面积:
							</td>
							<td style="width: 300px;text-align: left;">
								<input type="text" name="area" class="ldText" id="area" value="${area }"  />
							</td>
							<td style="width: 80px;text-align: right;">
								用户名:
							</td>
							<td style="width: 300px;text-align: left;">
								<input type="text" name="username" class="ldText" id="username" value="${username }"  />
							</td>
						</tr>
						<tr>
							<td style="width: 80px;text-align: right;">
								状态:
							</td>
							<td style="width: 300px;text-align: left;">
								<select id="status" name="status" class="ldText">
									<option value="">状态</option>
									<option value="0" <c:if test="${status eq '0'}">selected="selected"</c:if>>空白</option>
									<option value="1" <c:if test="${status eq '1'}">selected="selected"</c:if>>自租</option>
									<option value="2" <c:if test="${status eq '2'}">selected="selected"</c:if>>他租</option>
								</select>
							</td>
<!-- 							<td style="text-align: right;"> -->
<!-- 								<label for="trade">行业:&nbsp;</label> -->
<!-- 							</td> -->
<!-- 							<td class="tr_right"> -->
<!-- 								<select id="trade" name="trade"  class="ldText"> -->
<!-- 									<option value="">行业</option> -->
<%-- 									<c:forEach var="trade" items="${tradeList }"> --%>
<%-- 										<option value="${trade.itemName }" <c:if test="${trade.itemName eq tradeNum}">selected="selected"</c:if>>${trade.itemValue }</option> --%>
<%-- 									</c:forEach> --%>
<!-- 								</select> -->
<!-- 							</td> -->
							<td style="width: 80px;text-align: right;">
								等级:
							</td>
							<td style="width: 300px;text-align: left;">
								<select id="lv" name="lv"  class="ldText" >
									<option value="">等级</option>
									<option value="0" <c:if test="${lv eq '0'}">selected="selected"</c:if>>优</option>
									<option value="1" <c:if test="${lv eq '1'}">selected="selected"</c:if>>良</option>
									<option value="2" <c:if test="${lv eq '2'}">selected="selected"</c:if>>中</option>
								</select>
							</td>
							<td style="width: 80px;text-align: right;">
								价格:
							</td>
							<td style="width: 300px;text-align: left;">
								<input type="text" name="price" id="price" value="${price }" class="ldText" />
							</td>
							<td style="width: 80px;text-align: right;">
								手机号:
							</td>
							<td style="width: 300px;text-align: left;">
								<input type="text" name="tel" id="tel" value="${tel }" class="ldText" />
							</td>
							<td style="width: 80px;text-align: left;">
								<input type="submit" id="btn_search" name="btn_search" class="ldBtnBlue" style="text-align: right;" value="查询" />
							</td>
						</tr>

					</table>
					<input type="hidden" name="curPage" id="curPage" value="${curPage}" />
					<input type="hidden" name="totalPage" id="totalPage" value="${totalPage}" />
				</form>
		</div>
		<hr />
		<div>
			<table id="wallTable" border="0" cellspacing="0" cellpadding="0" width="80%" class="tablesorter-blue">
				<thead>
					<tr>
						<th>
							<span style="cursor: pointer" onclick="changeStatus('wallTable','all')">全</span>/<span style="cursor: pointer"
								onclick="changeStatus('wallTable','invert')">反</span>
						</th>
						<th>省市县</th>
						<th>乡镇</th>
						<th>地址</th>
						<th>姓名</th>
						<th>联系方式</th>
						<th>高*宽=面积</th>
						<th>级别</th>
						<th>价格</th>
						<th>创建时间</th>
						<th>客户名称</th>
						<th>行业</th>
						<th>租赁时间</th>
						<th>到期时间</th>
						<th>状态</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody>
					<c:forEach items="${list}" var="wall" varStatus="status">
						<tr ondblclick="view('${wall.id }','${wall.province }${wall.city }${wall.county }${wall.username }')"
							title="双击查看...">
							<td>
								<input name="checkName" type="checkbox" id="" value="${wall.id }" />
							</td>
							<td>${wall.province }${wall.city }${wall.county }</td>
							<td>${wall.town}</td>
							<td>${wall.address}</td>
							<td>${wall.username }</td>
							<td>${wall.tel }</td>
							<td>${wall.high }*${wall.width }=${wall.area }</td>
							<td>${wall.lvname }</td>
							<td>${wall.price }</td>
							<td>${wall.create_time }</td>
							<td>${wall.cname }</td>
							<td>${wall.tradename }</td>
							<td>${wall.renttime }</td>
							<td>${wall.endtime }</td>
							<td>
								<c:if test="${wall.status ==0 }">空白</c:if>
								<c:if test="${wall.status ==1 }">自租</c:if>
								<c:if test="${wall.status ==2 }">他租</c:if>
							</td>
							<td>
								<jt:check rightMark="wallUpdate">
									<a href="javascript:void();" onclick="updateItem('${wall.username }','${wall.id}')" class="ldBtnLink" >修改</a>
								</jt:check>
								<jt:check rightMark="wallDelete">
									<a href="wall/delete.do?id=${wall.id }" class="ldBtnLink" >删除</a>
								</jt:check>
							</td>
						</tr>
					</c:forEach>
				</tbody>
			</table>
		</div>
		<hr />
		<div>
			<div style="float: left;">
				<jt:check rightMark="wallBatchDelete">
					<input type="button" id="btn_batch_del" name="btn_batch_del" value="批量删除" class="ldBtnGray" />
				</jt:check>
				<jt:check rightMark="wallBatchExport">
					<input type="button" id="btn_export" name="btn_excport" value="批量导出" class="ldBtnGray" />
				</jt:check>
				<jt:check rightMark="wallInsert">
					<input type="button" id="btn_insert" name="btn_insert" value="新增" class="ldBtnGray" />
				</jt:check>
				&nbsp;
			</div>

			<div style="float: left;">
				<jt:check rightMark="wallBatchImport">
					<form action="wall/import.do" method="post" id="uploadFrom" enctype="multipart/form-data">
						<label>Excel批导入：</label>
						<input type="file" name="uploadFile" accept=".xls,.xlsx" style="width: 200px;" />
						<input type="submit" class="ldBtnGray" value="导入" />
						<a href="temp/temp.xls">模板下载</a>
					</form>
				</jt:check>
			</div>
			<div style="text-align: right;">
				<form id="pagerForm" method="post" name="pagerForm" action="wall/list.do">
					<input name="province" type="hidden" value="${province}" />
					<input name="city" type="hidden" value="${city }" />
					<input name="county" type="hidden" value="${county }" />
					<input type="hidden" name="endTime" value="${endTime }" />
					<input type="hidden" name="area" value="${area }" />
					<jt:pager action="pagerForm" />
				</form>
			</div>

		</div>
	</div>
</body>
</html>

